adventofcode | Advent of Code solutions | Learning library
kandi X-RAY | adventofcode Summary
kandi X-RAY | adventofcode Summary
Advent of Code solutions 2015-2021
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of adventofcode
adventofcode Key Features
adventofcode Examples and Code Snippets
Community Discussions
Trending Discussions on adventofcode
QUESTION
I can use the normal F2 rename variable functionality in regular python files in vscode. But not when editing python in a jupyter notebook.
When I press F2 on a variable in a jupyter notebook in vscode I get the familiar change variable window but when I press enter the variable is not changed and I get this error message:
No result. No result.
Is there a way to get the F2 change variable functionality to work in jupyter notebooks?
Here's my system info:
jupyter module version
...ANSWER
Answered 2022-Jan-17 at 02:49Notice that you put up a bug report in GitHub and see this issue: Renaming variables didn't work, the programmer replied:
Some language features are currently not supported in notebooks, but we are making plans now to hopefully bring more of those online soon.
So please wait for this feature.
QUESTION
Sorry for the spaghettiOs!
I am trying to do the Adventofcode tasks and this one got me stuck for a bit. I am a newbie into programming but trying my best to finish this task so probably I am doing everything by force. Can u guys help me or point into a right direction?
...ANSWER
Answered 2022-Mar-09 at 14:20As suggested on the first comment you received, you should first produce a string from the array you previously built, like this:
QUESTION
I'm trying to GET the content of a page using the Java 11 HttpClient. Since the page uses OAuth, I want to authenticate using my session cookie. I currently use the following code, inspired by this question:
...ANSWER
Answered 2021-Nov-04 at 14:38The solution is below using a proper CookieManager instead of hardcoding a header:
QUESTION
I'm working on Advent of Code with Zig and I'm at day 3. I've uploaded the code I wrote. The puzzle description and the code is here: https://github.com/secondspass/adventofcodeday3 . The code is in day3_part2.zig, the input file is day3.in. I run with zig run day3_part2.zig
.
I get one of two outputs when I run the code. Either the below integer overflow in the co2ScrubberRating
function.
ANSWER
Answered 2022-Feb-14 at 20:08This is because readToNumberList
is returning a pointer to stack memory that goes out of scope, which is undefined behaviour and not yet caught in debug builds.
QUESTION
The code works when the day1.js script is loaded in the index and if a certain snippet from the HTML template is pasted into the file, but it doesn't work when I switch to the page using ng-view with the same code. There is nothing in my day1controller. I'm pretty lost at this point and would appreciate some insight.
I keep getting the error
day1.js:5 Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
Here is my index:
...ANSWER
Answered 2021-Dec-23 at 03:51You have to use container for place your view.ng- view is a directive that works like a placeholder. It creates a placeholder where a corresponding view can be placed based on the configuration.
QUESTION
This is my code and my output doesn't even look like its right, I think the 0 and 1 aren't being concatenated to the variables.
...ANSWER
Answered 2021-Dec-27 at 11:25The thing is that you need ot apply the logic (count zeros and ones) for each bit position (or each column), not just once as your code does
The easiest is to iterate on the columns, use zip
to transpose from the rows, then for each find the most and lest common (one is the opposite of the other)
QUESTION
I cannot find a way to do simple tree traversal without recursion within the guidelines of the borrow checker.
Advent of Code 2021 Day 18 has numbers that can be represented either by a pair of numbers or by a value (perfect for Rust enums). There are also parts of the problem where I'm using a stack to traverse the tree so I'm using Rc>
to represent child nodes. This led me to the following representation:
ANSWER
Answered 2021-Dec-21 at 18:24The problem with your attempt is that the lifetime of the return value of node.borrow_mut()
is tied to node
, but you are attempting to store that result into a variable that has a caller-provided lifetime. When the current iteration's borrow_mut()
ends, the reference (used by left_node
) expires and you cannot store something with a shorter lifetime into a variable with a longer lifetime — the entire point of memory safety.
A workaround is to avoid concurrently using references (&
) and reference counting (Rc
). Using only Rc
, you can clone the child and replace the temporary variable:
QUESTION
I'm trying to solve the following code challenge from advent of code: problem description
Essentially, I'm receiving input in the form of lines representing coordinate lines on a grid, i.e.: x1,y1 -> x2,y2
. For the first part of the problem, I'm to draw these lines into a 2D array, then count the number of coordinates in the grid where lines have overlapped at least once. So far I've gotten to the point where I've successfully isolated which lines are valid (horizontal or vertical), and am trying to simply draw them onto the 2D array. For some bizarre reason that I can't pinpoint, my method is drawing only some of the lines onto the array, even though the lines are all identified as being valid that should be and are passed into the same code block that should be drawing the lines into the array. See the following code:
ANSWER
Answered 2021-Dec-12 at 01:20Sometimes x2 or y2 is smaller than x1 or y1, and your code isn't accounting for that - your loops are currently doing for (let y = line.y1; y <= line.y2; y++) {
, which will not iterate at all if the 2 starts out smaller than the 1.
Either identify the smaller or larger elements first, or identify which direction you need to iterate - with +1 or -1. Eg
QUESTION
The problem I am working on today is Advent of Code 2021 - Day 6: Lanternfish. The main excerpts of the problem have been included below to make sure this question is self contained.
suppose you have a lanternfish with an internal timer value of
3
:
- After one day, its internal timer would become
2
.- After another day, its internal timer would become
1
.- After another day, its internal timer would become
0
.- After another day, its internal timer would reset to
6
, and it would create a new lanternfish with an internal timer of8
.- After another day, the first lanternfish would have an internal timer of
5
, and the second lanternfish would have an internal timer of7
. A lanternfish that creates a new fish resets its timer to6
, not7
(because0 is included as a valid timer value). The new lanternfish starts with an internal timer of
8` and does not start counting down until the next day.Realizing what you're trying to do, the submarine automatically produces a list of the ages of several hundred nearby lanternfish (your puzzle input). For example, suppose you were given the following list:
...
ANSWER
Answered 2021-Dec-06 at 20:20Maybe you are over complicating. If you want to use a deque, use it to keep track of how many of each age you have. Then you just need to rotate left every day and add the new fish from bin 0 to bin 6 (well bin 7 before rotating):
QUESTION
My code is working but it is extremely long. So, I guess there is a way to make it shorter/more efficient.
The problem solved here is from Advent of Code 2021, Day 3, Part 1: https://adventofcode.com/2021/day/3
...ANSWER
Answered 2021-Dec-05 at 22:28Your right, especially your loops can be made much simpler and shorter.
first you should get rid of all those variables and loop though the strings as well.
Second you don't have to write the binary to decimal function yourself, you can use the built in int(num, 2)
.
If you apply just that you can already make your code much more compact.
I made a little sample if you need inspiration, but don't read any further if you want to figure it out yourself.
this is about how i would aproach this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install adventofcode
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page